import Vue from 'vue';
import Router from 'vue-router';
import amap from 'views/home/child/plan-management/Plan.vue'
import home from '../components/common/Home.vue'




Vue.use(Router);

 const routes = [
    {
        path :'/',
        redirect:'/shipinfo'
    },
    {
        path :'/login',
        name: 'Login',
        component : () => import('../views/login/Login.vue')
    },
    {
        path :'/home',
        name: 'Home',
        // component : () => import('../components/common/Home.vue'),
        component:home,
        redirect:"/shipinfo",
        children:[
            {
                path: "/shipinfo",
                component: () => import("../views/home/child/unmanned-ship/Shipinfo.vue"),
                meta: { title: '无人船信息管理' },
                
            },
            // {
            //     path: "/configuration",
            //     component: () => import("../views/home/child/unmanned-ship/Configuration.vue"),
            //     meta: { title: '配置信息管理' },
            // },
            {
                path: "/index",
                component:() => import("views/home/Index.vue"),
                meta: { title: '系统首页' },
            },
            {
                path: "/checkpoint",
                component:() => import("views/home/child/plan-management/CheckPoint.vue"),
                meta: { title: '检测点管理' },
            },
            {
                path :"/plan",
                component:() => import("views/home/child/plan-management/Plan.vue"),
                meta: { title: '计划管理' },
            },
            {
                path: "/planroute",
                component: () => import("views/home/child/plan-route/PlanRoute.vue"),
                meta:{title:"航线管理"}
            },
            {
                path :"/actionplan",
                name:'actionplan',
                component:() => import("views/home/child/plan-management/ActionPlan.vue"),
                meta: { title: '执行计划' },
            },
            {
                path :"/viewrunstatus",
                name:'viewrunstatus',
                component:() => import("views/home/child/plan-management/ViewRunStatus.vue"),
                meta: { title: '运行状态' },
            },
            {
                path :"/user",
                component:() => import("views/home/child/basic-info-manage/UserInfo.vue"),
                meta: { title: '用户信息管理' },
            },
            {
                path :"/organization",
                component:() => import("views/home/child/basic-info-manage/Organization.vue"),
                meta: { title: '组织机构管理' },
            }
        ]
    },
]

const router =new Router({
    routes
})

router.beforeEach((to,from,next) => {
    if (to.path==='/login') return next();
    const token = window.localStorage.getItem("token");
    if (!token) {
        // this.$message.error('用户登录信息失效,请重新登录')
        return next('./login');
    }
    else {
        return next ();
    }
})

    export default router;


